import { createRouter, RouteRecordRaw, createWebHistory, Router } from "vue-router";

let routes: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: "/index",
  },
  { path: "/index", component: () => import("@/pages/index.vue") },

  {
    path: "/pageA",
    component: () => import("@/pages/pageA/index.vue"),
    children: [{ path: "son", component: () => import("@/pages/pageA/sonPageA/index.vue") }],
  },
  {
    path: "/cssDemo",
    component: () => import("@/pages/pageB/index.vue"),
    // redirect: '/cssDemo/rotateCircle',
    children: [{ path: "rotateCircle", component: () => import("@/pages/pageB/01_rotateCircle/index.vue") }],
  },
  {
    path: "/404",
    component: () => import("@/pages/404page/index.vue"),
  },
  { path: "/:pathMatch(.*)*", name: "NotFound", redirect: "/404" },
];

let Router = createRouter({
  routes,
  history: createWebHistory(),
  scrollBehavior() {
    //路由跳转的滚动行为:回到顶端
    return { left: 0, top: 0 };
  },
});

export default Router;
